# 1.导包
import time
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

# 2.打开浏览器（创建浏览器驱动对象）
path = r"C:\Program Files\Python311\chromedriver.exe"
ser = Service(executable_path=path)  # Chrome浏览器驱动服务对象
driver = webdriver.Chrome(service=ser)  # 打开Chrome浏览器
driver.maximize_window()
# 3.输入网址
driver.get("http://121.43.169.97:8081/common/member/login")
# 4.页面操作
# 4.1登录
driver.find_element(By.ID, "keywords").send_keys("17912573189")
driver.find_element(By.ID, "password").send_keys("123456a")
driver.find_element(By.ID, "login-btn").click()
# 4.2切换身份:借款人
WebDriverWait(driver, 10).until(EC.visibility_of_element_located((By.XPATH, "//*[text()='借款账户']"))).click()
# 4.3点击额度申请
WebDriverWait(driver, 10).until(EC.visibility_of_element_located((By.LINK_TEXT, "申请额度"))).click()
# 4.4填写申请信息
WebDriverWait(driver, 10).until(EC.visibility_of_element_located((By.ID, "amount_account"))).send_keys("200000")
driver.find_element(By.NAME, "remark").send_keys("借钱买坦克300")
driver.find_element(By.ID, "verifycode").send_keys("8888")
driver.find_element(By.CSS_SELECTOR, ".btn-submit.btn-md").click()
# 5.等待2秒
time.sleep(2)
# 6.退出浏览器
driver.quit()
